<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\virtual\controller;

class AdminSetting extends \app\AdminRest
{
    protected $model;
    protected $admin_model;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->model = new \app\virtual\model\Config();
        $this->admin_model = new \app\massage\model\Admin();
    }
    public function configInfo()
    {
        $dis = ["uniacid" => $this->_uniacid];
        $data = $this->model->dataInfo($dis);
        $data["moor_phone_arr"] = !empty($data["moor_phone_arr"]) ? explode(",", $data["moor_phone_arr"]) : [];
        $data["winnerlook_phone_arr"] = !empty($data["winnerlook_phone_arr"]) ? explode(",", $data["winnerlook_phone_arr"]) : [];
        return $this->success($data);
    }
    public function configUpdate()
    {
        $input = $this->_input;
        $dis = ["uniacid" => $this->_uniacid];
        if(isset($input["reminder_admin_phone"])) {
            $input["reminder_admin_phone"] = !empty($input["reminder_admin_phone"]) ? implode(",", $input["reminder_admin_phone"]) : "";
        }
        if(isset($input["moor_phone_arr"])) {
            $input["moor_phone_arr"] = !empty($input["moor_phone_arr"]) ? implode(",", $input["moor_phone_arr"]) : "";
        }
        if(isset($input["winnerlook_phone_arr"])) {
            $input["winnerlook_phone_arr"] = !empty($input["winnerlook_phone_arr"]) ? implode(",", $input["winnerlook_phone_arr"]) : "";
        }
        $data = $this->model->dataUpdate($dis, $input);
        return $this->success($data);
    }
    public function phoneRecordList()
    {
        $input = $this->_param;
        $record_model = new \app\virtual\model\PlayRecord();
        $dis[] = ["uniacid", "=", $this->_uniacid];
        /*if(!empty($input["order_id"])) {
            $dis[] = ["out_id", "=", $input["order_id"]];
        }*/
        if(!empty($input["start_time"]) && !empty($input["end_time"])) {
            $dis[] = ["call_time", "between", $input["start_time"] . "," . $input["end_time"]];
        }
        $data = $record_model->dataList($dis, $input["limit"]);
        if(!empty($data["data"])) {
            foreach ($data["data"] as &$v) {
                if($this->_user["phone_encryption"] == 0) {
                    $v["phone_b"] = substr_replace($v["phone_b"], "****", 2, 4);
                }
            }
        }
        return $this->success($data);
    }
}

